#include <iostream>
using namespace std;
class Solution {
public:
	int findComplement(int num) {	
		//code 1
		/*int tmp = 1, n = num;
		while(n)
		{
			n >>= 1;
			tmp <<= 1;
		}
		return num ^ (tmp - 1);*/
		int valid = 0;
		int tmp = num;
		while (tmp > 0) {
			tmp /= 2;
			valid++;
		}

		return ~num & ((1 << valid) - 1);
	}
};
int main()
{
	int n = 5;
	int x = 0xffffffff;
	cout << ((n)&x) << endl;
}